let filesPath = [
    "src/App.vue",
    "src/",
    "src/assets/",
    "src/assets/logo.png",
    "src/assets/me.png",
    "src/assets/ranking.png",
    "src/assets/styles/",
    "src/assets/styles/common.css",
    "src/assets/styles/common.min.css",
    "src/assets/styles/common.scss",
    "src/components/",
    "src/components/HelloWorld.vue",
    "src/components/login.vue",
    "src/components/navList.vue",
    "src/main.js",
    "src/router/",
    "src/router/index.js",
    "src/store/",
    "src/store/index.js",
    "src/views/",
    "src/views/AboutView.vue",
    "src/views/detailView.vue",
    "src/views/endDetails.vue",
    "src/views/home.vue",
    "src/views/HomeView.vue",
    "src/views/personalCenter.vue",
    "src/views/RegisterNow.vue"
];

let result = [];
let rootDepth = filesPath[0].split('/').filter(part => part !== '').length; // 获取根节点深度
let rootName = filesPath[0].split('/')[rootDepth - 1]; // 根据深度获取根节点名称
let root = { name: rootName, depth: 0, fullPath: '', isDir: true, children: [] };

for (let path of filesPath) {
    let parts = path.split('/');
    let currentNode = root;
    for (let i = rootDepth; i < parts.length; i++) {
        let dirName = parts[i];
        let existingNode = currentNode.children.find(node => node.name === dirName);
        if (!existingNode) {
            let newNode = {
                name: dirName,
                depth: i - rootDepth + 1,
                fullPath: parts.slice(rootDepth, i + 1).join('/'),
                isDir: i < parts.length - 1,
                children: []
            };
            currentNode.children.push(newNode);
            currentNode = newNode;
        } else {
            currentNode = existingNode;
        }
    }
}

result.push(root);

console.log(result);